﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Configuration;

using SIPO.Library.DomainObject.Transaction;
using SIPO.Library.DataAccess.Transaction;
using System.Globalization;

namespace SIPO.Web.Lists.Transaction
{
    public partial class recMonitoringPostJurnal : BasePage
    {
        
        protected override void OnLoad(EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                recJurnalRepo recjurnaldal = new recJurnalRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);

                List<recJurnal> jurnal = recjurnaldal.GetListTanggal();
                if (jurnal != null)
                {
                    jurnal.ForEach(delegate(recJurnal debtor)
                    {
                        string bln = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(int.Parse(debtor.thnbln.Substring(4, 2)));
                        ddlPeriode1.Items.Add(new ListItem(bln + ", " + debtor.thnbln.Substring(0, 4), debtor.thnbln.Substring(0, 4)+ int.Parse(debtor.thnbln.Substring(4, 2)) + "01"  ));
                        DateTime ddl2 = Convert.ToDateTime("01"+ bln + debtor.thnbln.Substring(0, 4));
                        ddl2 = ddl2.AddMonths(1);
                        ddl2 = ddl2.AddDays(-1);
                        ddlPeriode2.Items.Add(new ListItem(bln + ", " + debtor.thnbln.Substring(0, 4), ddl2.ToString("yyyyMMdd")));


                    });

                    ddlPeriode1.Items.Insert(0, new ListItem("Periode Awal", "Periode Awal"));
                    ddlPeriode2.Items.Insert(0, new ListItem("Periode Akhir", "Periode Akhir"));
                }
                }
        }
    }
}